//
//  ViewController.m
//  Final
//
//  Created by Lenrony on 2021/12/2.
//  Copyright © 2021 Lenrony. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property(strong, nonatomic) UIImage* homeImage;
@property(strong, nonatomic) UIImage* searchImage;
@property(strong, nonatomic) UIImage* userImage;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //加载图片
    self.homeImage = [UIImage imageNamed:@"fangzi.png" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
    self.searchImage = [UIImage imageNamed:@"sousuo.png" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
    self.userImage = [UIImage imageNamed:@"renwu.png" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
    
    //设置字体大小、颜色等
    UITabBarController* mainController = [[UITabBarController alloc]init];
    mainController.tabBar.tintColor = [UIColor blueColor];
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:12.0f]} forState:UIControlStateNormal];
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:12.0f]} forState:UIControlStateSelected];
    
    //三个子控制器
    HomeViewController* hc = [[HomeViewController alloc]init];
    hc.tabBarItem.title = @"集市";
    hc.tabBarItem.image = self.homeImage;
    [mainController addChildViewController:hc];
    
    SearchViewController* sc = [[SearchViewController alloc]init];
    sc.tabBarItem.title = @"搜索";
    sc.tabBarItem.image = self.searchImage;
    [mainController addChildViewController:sc];
    
    UserViewController* uc = [[UserViewController alloc]init];
    uc.tabBarItem.title = @"我的";
    uc.tabBarItem.image = self.userImage;
    [mainController addChildViewController:uc];
    
    [mainController.tabBar setTintColor:[UIColor colorWithRed:50/255.0 green:153/255.0 blue:50/255.0 alpha:1.0]];
    //让程序从AppDelegate界面跳转到这里
    [self.navigationController setViewControllers: @[mainController]];
}


@end

